﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using DatabaseHelper.Core.Models;
using DatabaseHelper.Core.Services.Interfaces;
using DatabaseHelper.Core.DAL.Interfaces;
using DatabaseHelper.Core.DAL;

namespace DatabaseHelper.Core.Services
{
    public class DatabaseInfoServices : IDatabaseInfoServices
    {
        private static ISqlServerDAL DAL = new SqlServerDAL();

        public DatabaseInfoServices()
        {
        }

        public async Task<List<ColumnViewEntity>> GetAllColumnsInDatabase(string connectString)
        {
            (DAL as BaseDatabaseDAL).ConnectTo(connectString);
            var databaseName = await DAL.GetDatabaseName();
            var columns = await DAL.GetAllColumns();

            columns.ForEach(c => c.DatabaseName = databaseName);
            return columns;
        }
    }
}
